<script type="text/javascript">
    function autoPass(){
        if($("#userType").val()==1)
        {
            $("#username").val('student');
            $('#password').val('123456');
        }
        else if($("#userType").val()==2)
        {
            $("#username").val('teacher');
            $("#password").val('123456');
        }
        else
        {
            $("#username").val('');
            $("#password").val('');
        }
    }
</script>
	<!--left begin-->
		<div id="sidebar_left">
            <?php if($_SESSION['sid']==''){?>
			<dl>
				<dt>
					<a href="#">用户登录</a>
				</dt>
				<dd>
                     <form action="#" method="POST" class="well" id="login" onsubmit="return checkbox(new Array(new Array('username','用户名不能为空'),new Array('password','密码不能为空')));">
						<div class="control-group">
							<label>选择用户类型:</label>
							<select name="userType" id="userType" onchange="autoPass()">
                                <option value="0">学生/老师</option>
                                <option value="1">学生测试账号</option>
                                <option value="2">老师测试账号</option>
                            </select>
						</div>
                         <div class="control-group">
							<label>用户名(学号或工号):</label>
							<input id="username" class="focused span2" type="text" style="width:165px;" name="username" value="">
						</div>
						<div class="control-group">
							<label>密码:</label>
							<input id="password" class="focused span2" type="password" value="" style="width:165px;" name="pwd">
						</div>
						<div class="control-group ">
                                <button class="btn btn-primary" name="submit" type="submit">提 交</button>
                                <button type="reset" class="btn">取 消</button>
						</div>
                    </form>
				</dd>
			</dl>
            <?php
            }else{       
            ?>
            <dl>
                    <dt>
                        <a href="#">个人信息</a>
                    </dt>
                    <dd>
                    <div class="user_info">
                        <div class="headshow">
                            <?php if($_SESSION['type']==3){?>
                            <img height="45px" width="45px" src="resources/images/graduated.png"/>
                            <?php }?>
                            <?php if($_SESSION['type']==2){?>
                            <img src="<?php if($_SESSION['photo']==''){echo 'resources/images/user3.png';}else{echo "backstage/".$_SESSION['photo'];}?>" alt="用户头像" height="50" width="50"/>
                            <?php }?>
                            <?php if($_SESSION['type']==0){?>
                            <img height="45px" width="45px" src="resources/images/webmaster.png" />
                            <?php }?>
                        </div>
                        <div class="headleftinfo">
                            <span class="wh40">欢迎您:</span><span class="wh60"><?php echo mb_substr($_SESSION['realname'],0,4,'utf-8')?></span><span class="wh40">(<?php switch($_SESSION['type']){ case 0: echo '管理员';break;case 2:echo '老师';break;case 3:echo '学生';break;default:echo '身份加载失败';}?>)</span>
                            <p>您是第&nbsp;<?php echo $_SESSION['logintimes']+1?>&nbsp;次登陆</p>
                        </div>
                        
                        
                    </div>

                    <div class="moreinfo" >
                        <?php if($_SESSION['type']==2){?>
                    <span><a href="./teacher" target="_blank">后台管理</a></span>
                        <?php } ?>
                            <span><a href="?do=myaccount">个人中心</a></span><span><a href="?do=loginout">退出登陆</a></span>
                    </div>
                    </dd>
        </dl>
        <?php
        }
        ?>

        <dl>
                <dt>
                        <a href="#">热门课程</a>
                </dt>
                <dd>
                        <ul>
                                <?php 
                                         $sql_course = "select id,title,teacherid,times from nettteach_course where state='0' and sort ='0' order by times desc limit 0,5 ";
                                         $result_course = $db -> query($sql_course);
                                         while($row_course = $db ->fetch_array($result_course))
                                        {
                                ?>
                                <li><a style="color:blue" target=_blank href="?do=viewcourse&courseid=<?php echo $row_course['id']?>" title=""><?php echo $row_course['title']?></a> <br/>主讲老师:&nbsp;<?php echo (fs_get_objinfo("nettteach_member","id",$row_course['teacherid'], "realname"))?><br/>点击次数:&nbsp;<?php echo $row_course['times']?></li>
                                <?php }?>
                        </ul>
                </dd>
        </dl>

        <dl>
                <dt>
                        <a href="#">热门下载</a>
                </dt>
                <dd>
                        <ul>
                                <?php 
                                         $sql_courseware = "select id,writerid,title,times from nettteach_courseware where 1=1 order by times desc limit 0,5 ";
                                         $result_courseware = $db -> query($sql_courseware);
                                         while($row_courseware = $db ->fetch_array($result_courseware))
                                        {
                                ?>
                                <li><a style="color:blue" href="?do=leftcourseware&coursewareid=<?php echo $row_courseware['id']?>&teacherid=<?php echo $row_courseware['writerid']?>" title=""><?php echo $row_courseware['title']?></a> <br/>主讲老师:&nbsp;<?php echo (fs_get_objinfo("nettteach_member","id",$row_courseware['writerid'], "realname"))?><br/>下载次数:&nbsp;<?php echo $row_courseware['times']?></li>
                                <?php }?>
                        </ul>
                </dd>
        </dl>
    </div>
    <!--left end-->